home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / CBGRX103.ZIP / contrib / libgrx / src / pifillp.c < prev    next >
Text File  |  1993-12-06  |  3KB  |  80 lines

  1. /**
  2.  ** PIFILLP.C
  3.  **
  4.  **  Copyright (C) 1992, Csaba Biegl
  5.  **    820 Stirrup Dr, Nashville, TN, 37221
  6.  **    csaba@vuse.vanderbilt.edu
  7.  **
  8.  **  This file is distributed under the terms listed in the document
  9.  **  "copying.cb", available from the author at the address above.
  10.  **  A copy of "copying.cb" should accompany this file; if not, a copy
  11.  **  should be available from where this file was obtained.  This file
  12.  **  may not be distributed without a verbatim copy of "copying.cb".
  13.  **  You should also have received a copy of the GNU General Public
  14.  **  License along with this program (it is in the file "copying");
  15.  **  if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  16.  **  Cambridge, MA 02139, USA.
  17.  **
  18.  **  This program is distributed in the hope that it will be useful,
  19.  **  but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.  **  GNU General Public License for more details.
  22.  **/
  23.  
  24. #include "p8514a.h"
  25.  
  26. static int bg_mixtable[] = {
  27.     BSS_BKGDCOL | MIX_SRC,          /* C_SET */
  28.     BSS_BKGDCOL | MIX_XOR,          /* C_XOR */
  29.     BSS_BKGDCOL | MIX_OR,          /* C_OR  */
  30.     BSS_BKGDCOL | MIX_AND          /* C_AND */
  31. };
  32.  
  33. void _GrPIFillPattern(int x,int y,int width,GrPattern *p)
  34. {
  35.     if(width <= 0) return;
  36.     if(p->gp_ispixmap) {
  37.         int patw = p->gp_pxp_width;
  38.         int xpos = (x + CURC->gc_xoffset) % patw;
  39.         int ypos = (y + CURC->gc_yoffset) % p->gp_pxp_height;
  40.         while(width > 0) {
  41.         int curw = MIN(width,(patw - xpos));
  42.         _GrPIPixCopy(CURC,PIX_ADDR(CURC,x,y),
  43.             (GC *)(&p->gp_pxp_source),PIX_ADDR(&p->gp_pxp_source,xpos,ypos),
  44.             curw,1,p->gp_pxp_oper
  45.         );
  46.         width -= curw;
  47.         x += curw;
  48.         xpos = 0;
  49.         }
  50.         return;
  51.     }
  52.     if(CURC->gc_onscreen) {
  53.         int fgc,bgc,bits,fgop,bgop;
  54.         x += CURC->gc_xoffset;
  55.         y += CURC->gc_yoffset;
  56.         bits = p->gp_bmp_data[y % p->gp_bmp_height];
  57.         fgc  = p->gp_bmp_fgcolor;
  58.         bgc  = p->gp_bmp_bgcolor;
  59.         fgop = C_OPER(fgc);
  60.         bgop = C_OPER(bgc);
  61.         WaitQueue(6);
  62.         outpw(FRGD_COLOR,fgc);
  63.         outpw(BKGD_COLOR,bgc);
  64.         outpw(FRGD_MIX,_GrPIMixTable[fgop]);
  65.         outpw(BKGD_MIX,bg_mixtable[bgop]);
  66.         outpw(CUR_X,x);
  67.         outpw(CUR_Y,y);
  68.         WaitQueue(6);
  69.         outpw(MAJ_AXIS_PCNT,(width - 1));
  70.         outpw(MULTIFUNC_CNTL,(PATTERN_L | (bits << 1)));
  71.         outpw(MULTIFUNC_CNTL,(PATTERN_H | (bits >> 3)));
  72.         outpw(MULTIFUNC_CNTL,(PIX_CNTL | MIXSEL_PATT));
  73.         outpw(CMD,(CMD_LINE | LINETYPE | VECDIR_000 | DRAW | PLANAR | WRTDATA));
  74.         outpw(MULTIFUNC_CNTL,(PIX_CNTL | 0));
  75.         return;
  76.     }
  77.     _GrP8FillPattern(x,y,width,p);
  78. }
  79.  
  80.